document.write('<script src="VanillaTilt.js"></script>');
var h = document.documentElement.clientHeight;
function easeOutBounce(x) {
    const n1 = 7.5625;
    const d1 = 2.75;
    
    if (x < 1 / d1) {
        return n1 * x * x;
    } else if (x < 2 / d1) {
        return n1 * (x -= 1.5 / d1) * x + 0.75;
    } else if (x < 2.5 / d1) {
        return n1 * (x -= 2.25 / d1) * x + 0.9375;
    } else {
        return n1 * (x -= 2.625 / d1) * x + 0.984375;
    }
    }
var scrollSmoothTo = function (position) {
    if (!window.requestAnimationFrame) {
        window.requestAnimationFrame = function (callback, element) {
            return setTimeout(callback, 17);
        };
    }
    // 当前滚动高度
    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
    // 滚动step方法
    var step = function () {
        // 距离目标滚动距离
        var distance = position - scrollTop;
        // 目标滚动位置
        scrollTop = scrollTop + distance / 5;
        if (Math.abs(distance) < 1) {
            window.scrollTo(0, position);
        } else {
            window.scrollTo(0, scrollTop);
            requestAnimationFrame(step);
        }
    };
    step();
};
function capture(data) {//获取当前点击哪个元素
    switch (data.id) {
        case "page_1_down":
            scrollSmoothTo(h);
            break;
        case "page_2_down":
            scrollSmoothTo(2 * h);
            break;
        case "page_2_up":
            scrollSmoothTo(0);
            break;
        case "page_3_up":
            scrollSmoothTo(h);
            break;
    }
}
$(function () {
    VanillaTilt.init(document.querySelector(".card_1"), {
        max: 10,
        speed: 200,
        glare: false,   // 发光效果
        "max-glare": 0.5,
        scale: 1,//缩放
        // 调整旋转角度
        gyroscopeMinAngleX: -1,     // This is the bottom limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the left border of the element;
        gyroscopeMaxAngleX: 1,      // This is the top limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the right border of the element;
        gyroscopeMinAngleY: -1,     // This is the bottom limit of the device angle on Y axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the top border of the element;
        gyroscopeMaxAngleY: 1,
    });

    VanillaTilt.init(document.querySelector(".card_2"), {
        max: 10,
        speed: 200,
        glare: false,   // 发光效果
        "max-glare": 0.5,
        scale: 1,//缩放
        // 调整旋转角度
        gyroscopeMinAngleX: -1,     // This is the bottom limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the left border of the element;
        gyroscopeMaxAngleX: 1,      // This is the top limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the right border of the element;
        gyroscopeMinAngleY: -1,     // This is the bottom limit of the device angle on Y axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the top border of the element;
        gyroscopeMaxAngleY: 1,
    });
    VanillaTilt.init(document.querySelector(".card_3"), {
        max: 10,
        speed: 200,
        glare: false,   // 发光效果
        "max-glare": 0.5,
        scale: 1,//缩放
        // 调整旋转角度
        gyroscopeMinAngleX: -1,     // This is the bottom limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the left border of the element;
        gyroscopeMaxAngleX: 1,      // This is the top limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the right border of the element;
        gyroscopeMinAngleY: -1,     // This is the bottom limit of the device angle on Y axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the top border of the element;
        gyroscopeMaxAngleY: 1,
    });
    VanillaTilt.init(document.querySelector(".card_4"), {
        max: 10,
        speed: 200,
        glare: false,   // 发光效果
        "max-glare": 0.5,
        scale: 1,//缩放
        // 调整旋转角度
        gyroscopeMinAngleX: -1,     // This is the bottom limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the left border of the element;
        gyroscopeMaxAngleX: 1,      // This is the top limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the right border of the element;
        gyroscopeMinAngleY: -1,     // This is the bottom limit of the device angle on Y axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the top border of the element;
        gyroscopeMaxAngleY: 1,
    });
})